package 实验六;

import java.io.IOException;
import java.util.Scanner;


public class TestSystem {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		Student stuarr[] = new Student[100];
		Course csarr[] = new Course[100];
		Professor proarr[] = new Professor[100];
		int a = 0;
		while (a == 0) {
			System.out.println("1.新建学生\n"+"2.新建教师\n"+
					"3.教师开课\n"+"4.学生选课\n"+"5.学生退课\n"+"6.打印学生课表\n");
					System.out.println("请输入编号：");
					int x = sc.nextInt();
						switch(x) {
						case 1:
							System.out.println("请输入学号：");
							String s1 = sc.next();
							System.out.println("请输入姓名：");
							String s2 = sc.next();
							System.out.println("请输入性别：");
							String s3 = sc.next();
							Student s = new Student(s1,s2,s3);
							for (int i=0;i<=stuarr.length-1;i++) {
								if (stuarr[i] == null) {
									stuarr[i] = s;
									s.print();
									break;
								}
							}
							break;
						case 2:
							System.out.println("请输入教师编号：");
							String s4 = sc.next();
							System.out.println("请输入姓名：");
							String s5 = sc.next();
							System.out.println("请输入性别：");
							String s6 = sc.next();
							Professor p = new Professor(s4,s5,s6);
							for (int i=0;i<=proarr.length-1;i++) {
								if (proarr[i] == null) {
									proarr[i] = p;
									p.print();
									break;
								}
							}
							break;
						case 3:
							System.out.println("请输入教师编号：");
							String s7 = sc.next();
							for (int i=0;i<=proarr.length-1;i++)
							{
								if (proarr[i] == null)
									break;
								if (s7.equals(proarr[i].No)) {
									System.out.println("请输入课程号：");
									String s8 = sc.next();
									System.out.println("请输入课程名：");
									String s9 = sc.next();
									System.out.println("请输入上课地点：");
									String s10 = sc.next();
									System.out.println("请输入上课时间：");
									String s11 = sc.next();
									System.out.println("请输入所属学期：");
									String s12 = sc.next();
									System.out.println("请输入学分：");
									int ix = sc.nextInt();
									Course c = new Course(s8,s9,s10,s11,s12,ix,proarr[i]);
									for (int j=0;j<=csarr.length-1;j++) {
										if (csarr[j] != null && j == csarr.length-1)
											break;
										if (csarr[j] == null) {
											csarr[j] = c;
											System.out.println("开课成功！");
											break;
										}
									}
								}
							}
							break;
						case 4:
							System.out.println("请输入学生学号：");
							String s13 = sc.next();
							for (int i=0;i<=stuarr.length-1;i++) {
								if (stuarr[i] == null)
									break;
								if (s13.equals(stuarr[i].No)) {
									System.out.println("请输入课程名：");
									String s14 = sc.next();
									for (int j=0;j<=csarr.length-1;j++) {
										if (csarr[j] == null)
											break;
										if (s14.equals(csarr[j].Cname)) {
											stuarr[i].addSCourse(csarr[j]);
											System.out.println("选课成功！");
											break;
										}
									}
								}
							}
							break;
						case 5:
							System.out.println("请输入学生学号：");
							String s15 = sc.next();
							for (int i=0;i<=stuarr.length-1;i++) {
								if (stuarr[i] == null)
									break;
								if (s15.equals(stuarr[i].No)) {
									System.out.println("请输入课程名：");
									String s16 = sc.next();
									for (int j=0;j<=stuarr[i].SC.length-1;j++) {
										if (stuarr[i].SC[j] == null)
											break;
										if (s16.equals(stuarr[i].SC[j].Cname)) {
											 stuarr[i].SC[j] = null;
											 System.out.println("退课成功！");
											 break;
										}
									}
								}
							}
							break;
						case 6:
							System.out.println("请输入学生学号：");
							String s17 = sc.next();
							for (int i=0;i<=stuarr.length-1;i++) {
								if (stuarr[i] ==null)
									break;
								if (s17.equals(stuarr[i].No)) {
									stuarr[i].printSC();
									break;
								}
							}
							break;
						default:
							a = 1;
							break;
						}
		}
		sc.close();
		System.exit(0);
	}
}